
function random(min,max){
    return Math.floor(Math.random()*(max-min+1)+min)
}

var t = setInterval(function(evt){

    
    var imgObj = document.createElement('img')
    imgObj.src = './star.gif'
    imgSize = random(20,80)
    imgObj.width = imgSize
    imgObj.height = imgSize 
    var e = evt || window.event
    var maxRangeW = (window.innerWidth || document.documentElement.clientWidth) - imgObj.width
    var maxRangeH = (window.innerHeight || document.documentElement.clientHeight) - imgObj.height
    imgRangeW = random(0,maxRangeW)
    imgRangeH = random(40,maxRangeH)
    imgObj.style.position = 'absolute'
    imgObj.style.left = imgRangeW
    imgObj.style.top = imgRangeH
    document.body.appendChild(imgObj)
},1000)

var num2 = 600
var d = setInterval(function(){
    var divObj = document.querySelector('.box1-2')
    num2 -= 5
    divObj.style.width = num2 +'px'
    console.log(divObj) 
    if(num2 ==0){
        clearInterval(t)
        clearInterval(d)
        document.body.onclick = null
        document.querySelector('.box2').style.display = 'block'
        document.querySelector('.totalScore').innerText = num
    }
},200)


var num = 0
document.body.onclick = function(evt){
    var e = evt || window.event 
    var target = e.target || e.srcElement
    if(target.nodeName === 'IMG'){ 
        document.body.removeChild(target)
        num++
        document.querySelector('.score').innerText = num
    }
}